﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace CoreModule.Converters
{
    /// <summary>
    /// 血压等级 
    /// </summary>
    public class PressureLevelToColorConverter : IValueConverter
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Color myColor = (Color)ColorConverter.ConvertFromString("#EDD149");
            SolidColorBrush myBrush = new SolidColorBrush(myColor);
            if (value == null)
            {
                return myBrush;
            }
            PressureLevel pressureLevel = (PressureLevel)value;
            switch (pressureLevel)
            {
                case PressureLevel.None:
                    myColor = (Color)ColorConverter.ConvertFromString("#11A84D");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PressureLevel.Normal:
                    myColor = (Color)ColorConverter.ConvertFromString("#11A84D");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PressureLevel.Lower:
                    myColor = (Color)ColorConverter.ConvertFromString("#F58B00");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PressureLevel.NormalHigh:
                    myColor = (Color)ColorConverter.ConvertFromString("#11A84D");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PressureLevel.High1:
                    myColor = (Color)ColorConverter.ConvertFromString("#EB1C2A");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PressureLevel.High2:
                    myColor = (Color)ColorConverter.ConvertFromString("#EB1C2A");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PressureLevel.High3:
                    myColor = (Color)ColorConverter.ConvertFromString("#EB1C2A");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PressureLevel.JustHigh:
                    myColor = (Color)ColorConverter.ConvertFromString("#EB1C2A");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                default:
                    return myBrush;
            }
             
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
